<?php
    $submit = $_POST['submit'];
    if(!isset($submit)){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>安装界面 -- Powered by Talking</title>
<style type="text/css">
html,body{margin: 0px; padding: 0px; background-color: #D7D7D7; font:12px "Lucida Grande",Verdana,Lucida,Helvetica,Arial,sans-serif; color:#646464;}
#setup{margin: 108px auto 0px; width: 546px;}
#setup_top{width: 546px; height: 8px; background: url(./static/images/cap-top.png);}
#setup_body{padding: 0px 40px; padding-bottom: 18px; background:transparent url(./static/images/cap-bg.png) repeat-y;}
#logo{padding-top: 20px; display: block;}     
p{margin:0px 0px 14px 10px;}
label{display:block; margin:0 0 7px 0; line-height:12px;}
.text-long{border: 1px solid #ddd; background:url(./admin/static/images/input-shaddow.gif) no-repeat; color: #646464; padding: 5px 7px; margin-right:10px; width: 420px;}
.button{width:50px; height:30px; border:solid 1px #EEEEEE; -webkit-border-radius:13px; -moz-border-radius:13px; color:#646464; cursor:pointer; border:solid 1px #DDD;}
#setup_bottom{width: 546px; height: 15px; background:transparent url(./static/images/cap-bottom.png) no-repeat;}
</style>
<script type="text/javascript" src="./templates/default/js/jquery-1.3.min.js"></script> 
</head>

<body>
<div id="setup">
    <div id="setup_top"></div>
    <div id="setup_body">
        <div id="logo"><img src="./admin/static/images/logo2.gif" /></div>  
        <div style="margin-top: 20px;">
        <form action="./install.php" method="post" name="form">
            <p>
                <label>初始化管理员:</label>
                <input type="text" class="text-long" name="username"/>
            </p>
            <p>
                <label>初始化密码:</label>
                <input type="text" class="text-long" name="userpass"/>
            </p>
            <p>
                <label>系统邮箱:</label>
                <input type="text" class="text-long" name="usermail"/>
            </p>
            <p>                                     
                <input type="submit" value="安装" class="button" name="submit"/>
            </p>
        </form>
        </div>   
    </div>
    <div id="setup_bottom"></div>
</div>
</body>
</html>
<?php
    }
    else{
        require(dirname(__FILE__).'/config_db.php');
        require(dirname(__FILE__).'/include/mysql.class.php');
        $username = $_POST['username'];
        $userpass = $_POST['userpass'];
        $usermail = $_POST['usermail'];
        $userpass = strtoupper(sha1($userpass));
        $sql = "insert into talking_user(UserName,UserPass,UserEmail,UserGroup) values('$username','$userpass','$usermail',6)";
        $link = @MysqlUtil::getInstance($mysql_host,$mysql_user,$mysql_pass,$mysql_dbname,$mysql_port);
          if($link->execute($sql)){
              echo '系统搭建成功'; 
          }            
          else{
              echo '执行错误';
          }
    }
?>